﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data.SqlClient;
using System.Data;

namespace Biblioteca.Conexao
{
    public class Conexao2
    {

        private static Conexao2 instancia;


        private Conexao2()
        {

        }


        public static Conexao2 obterConexao2()
        {

            if (instancia == null)
            {

                instancia = new Conexao2();

            }

            return instancia;


        }


        public SqlConnection conectar()
        {


            SqlConnection Con;

            string caminhoSQL = @"Data Source=.\SQL2008Express;Initial Catalog=vendamais;UId=sa;Password=12345;";
            // string caminhoSQL = @"Data Source=PC-VALENTINA\SQLEXPRESS;Initial Catalog=vendamais;UId=teste;Password=123;";
            try
            {

                Con = new SqlConnection(caminhoSQL);

                Con.Open();

                return Con;

            }
            catch (Exception e)
            {

                throw e;

            }




        }


        public void desconectar(SqlConnection sqlCon)
        {


            try
            {
                sqlCon.Close();
                sqlCon.Dispose();

            }
            catch (Exception e)
            {

                throw e;
            }



        }




    }
}
